import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:potato_music_app/application.dart';

class MusicSplashPage extends StatefulWidget {
  @override 
  _SplashPageState createState() => _SplashPageState();
}

class _SplashPageState extends State<MusicSplashPage> {
  
  @override
  void initState() {
    // Application.goToPage(context, Routes.home, replace: true);
    Future.delayed(Duration(milliseconds: 5000)).then((v) {
      Application.goToTabbarPage(context);
    });
    super.initState();
  }
  
  @override
  Widget build(BuildContext context) {
    ScreenUtil.instance = ScreenUtil(width: 750, height: 1334)..init(context);
    return Scaffold(
      backgroundColor: Colors.white,
      body: Container(
        width: double.infinity,
        height: double.infinity,
        child: Stack(
          children: <Widget>[
            SplashLogoWidget(),
            SplashBottomTextWidget()
          ],
        )
      
      )
    );
  }
}

class SplashBottomTextWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Positioned(
      bottom: 30,
      left: 0,
      right: 0,
      child: Center(
        child: Text(
          '腾讯云计算提供技术服务',
          style: new TextStyle(
            fontFamily: 'PingFang SC',
            color: Color(0xFF9A9A9A),
            fontSize: 14
          ),
        ),
      ),
    );
  }
}

class SplashLogoWidget extends StatelessWidget {
  @override
  Widget build (BuildContext context) {
    return Container(
      width: ScreenUtil().setWidth(750),
      height: ScreenUtil().setHeight(1334),
      child: Center(
        child: Center(
          child: Image.asset(
            'assets/images/app-logo-cricle.png',
            width: 70,
            height: 70
          )
        )
      )
    );
  }
}